
from fastapi import APIRouter

from config.dependencies import RoleServiceDep
from schemas.users import RoleResponse, RoleCreate, RoleUpdate, RolesResponse

roles = APIRouter(prefix="/roles", tags=["roles"])

@roles.post('/', response_model=RoleResponse)
def create_role(role_data: RoleCreate, service: RoleServiceDep):
    return service.create_role(role_data)


@roles.delete('/')
def delete_role(role_id: int, service: RoleServiceDep):
    return service.delete_role(role_id)


@roles.put('/', response_model=RoleResponse)
def update_role(role_data: RoleUpdate, service: RoleServiceDep):
    return service.update_role(role_data)


@roles.get('/', response_model=RolesResponse)
def get_roles(page: int | None = None, size: int | None = None, service: RoleServiceDep = RoleServiceDep):
    return service.filter_roles(page, size)

@roles.get('/role/', response_model=RoleResponse)
def get_role_by_id(role_id: int, service: RoleServiceDep = RoleServiceDep):
    return service.get_role_by_id(role_id)